﻿using UnityEngine;
using System.Collections;

public class Selection : MonoBehaviour {

	// Use this for initialization
    bool taClicado = false;
	void Awake()
    {
        save();
    }
    void Start () 
    {
        this.gameObject.AddComponent("BoxCollider2D");
        save();
	}
	
	// Update is called once per frame
	void Update () 
    {
        if (!taClicado)
        {
            Color32 cor = Color.black;
            cor.a = 0;
            this.renderer.material.color = cor;
        }
        else
        {
            Color32 cor = Color.white;
            cor.a = 255;
            this.renderer.material.color = cor;
        }
	}
    void OnMouseDown()
    {
        if (!taClicado)
        {
            taClicado = true;
            PlayerPrefs.SetInt(this.gameObject.name, 1);
            PlayerPrefs.Save();
        }
        else
        {
            taClicado = false;
            PlayerPrefs.SetInt(this.gameObject.name, 0);
            PlayerPrefs.Save();
        }
    }
    private void save()
    {
        if (PlayerPrefs.GetInt(this.gameObject.name) == 1)
        {
            taClicado = true;
        }
        else
        {
            taClicado = false;
        }
    }
}
